<extend name="./base"/>
<block name="body">
    <form class="form-inline" method="post" action="/Bailey/index.php/Admin/Question/typeadd">
        <div class="form-group">
            <label>名称</label>
            <input type="text" name="name" class="form-control" placeholder="输入题目类型">
        </div>
        <button type="submit" class="btn btn-default">添加</button>
    </form>
    <table class="table">
        <thead>
        <tr>
            <th>#</th>
            <th>名称</th>
            <th>删除</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="list" item="vo">
            <tr>
                <th>{$vo.id}</th>
                <td>{$vo.name}</td>
                <td data-id="{$vo.id}" class="del">删除</td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <include file="./Application/Admin/View/default/Public/question_type.html" />
    <script>
        $(function () {
            $('td.del').click(function () {
                var r=confirm("是否确认删除该项");
                if(!r){
                    return false;
                }
                var id = $(this).data('id');
                var _this = $(this);
                $.post(
                        '/Bailey/index.php/Admin/Question/typedel',
                        {id: id},
                        function (e) {
                            if (e == 1) {
                                _this.parent().remove();
                            }
                            if (e == 2) {
                                alert('删除失败');
                            }
                        });
            })
        })
    </script>
</block>
